package cn.videoview;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private Button btnVideoView;
    private Button btnSurfaceView;
    private Button btnSurfaceViewAndMediaController;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initView();
        initListener();
    }

    private void initListener() {
        btnVideoView.setOnClickListener(this);
        btnSurfaceView.setOnClickListener(this);
        btnSurfaceViewAndMediaController.setOnClickListener(this);
    }

    //初始化组件
    private void initView() {
        btnVideoView = findViewById(R.id.btnVideoView);
        btnSurfaceView = findViewById(R.id.btnSurfaceView);
        btnSurfaceViewAndMediaController = findViewById(R.id.btnSurfaceViewAndMediaController);
    }

    @Override
    public void onClick(View v) {
        Intent intent;
        switch (v.getId()) {
            case R.id.btnVideoView:
                intent = new Intent(MainActivity.this, FirstActivity.class);
                startActivity(intent);
                break;
            case R.id.btnSurfaceView:
                intent = new Intent(MainActivity.this, SecondActivity.class);
                startActivity(intent);
                break;
            case R.id.btnSurfaceViewAndMediaController:
                intent = new Intent(MainActivity.this, ThirdActivity.class);
                startActivity(intent);
                break;
        }
    }
}
